package com.gitee.zhanyao.single.util;

import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

import java.io.IOException;
import java.io.InputStream;

public class FileUtil {

    /**
     * 读取 resources 中的资源文件
     * 不能直接 getFile()，会导致打包成jar后获取不到文件
     * @param fileFullPath 如：static/js/app.js
     * @return Resource
     * @throws IOException
     */
    public static Resource resourceLoader(String fileFullPath) throws IOException {
        return new ClassPathResource(fileFullPath);
    }

    public static InputStream resourceLoaderToInputStream(String fileFullPath) throws IOException {
        return resourceLoader(fileFullPath).getInputStream();
    }

}
